package com.bgq365.study.springboot2.boot02web.acutuator.health;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class MyConHealthIndicator extends AbstractHealthIndicator {
    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        Map<String, Object> res = new HashMap<>();
        if (1 == 1) {
            builder.up();
            res.put("code",100);
            res.put("msg","success");
        } else {
            builder.status(Status.OUT_OF_SERVICE);
            res.put("code",500);
            res.put("msg","failed");
        }
        builder.withDetails(res);

    }
}
